package com.zzyl.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.zzyl.dto.NursingProjectPlanDto;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.mapper.NursingProjectPlanMapper;
import com.zzyl.service.NursingProjectPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class NursingProjectPlanServiceImpl implements NursingProjectPlanService {

    @Autowired
    private NursingProjectPlanMapper nursingProjectPlanMapper;

    //新增项目计划
    @Override
    public void addList(List<NursingProjectPlanDto> projectPlans) {
        //转换
        List<NursingProjectPlan> projectPlanList = projectPlans.stream()
                .map(v -> BeanUtil.toBean(v, NursingProjectPlan.class))
                .collect(Collectors.toList());
        nursingProjectPlanMapper.addList(projectPlanList);

    }

    //删除项目计划
    @Override
    public void removeList(List<Long> ids) {
        nursingProjectPlanMapper.removeList(ids);
    }

    //删除
    @Override
    public void deleteByNursingPlanId(Long id) {
        nursingProjectPlanMapper.deleteByNursingPlanId(id);
    }
}
